package top.xmj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.xmj.config.interceptor.UserLoginInterceptor;


/**
 *
 * @author 冰咖啡
 * @Date:2/12/2022 下午 9:36
 * @Description: 添加拦截器
 *
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 注册自定义拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login",  //登录界面
                        "/user/info",
                        "/websocket/**",
                        "/**/*.html",                //html静态资源
                        "/**/*.js",                  //js静态资源
                        "/**/*.css"                  //css静态资源
                );//开放登录路径
    }

}